package com.baosight.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import com.netflix.loadbalancer.AvailabilityFilteringRule;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.RetryRule;
import com.netflix.loadbalancer.RoundRobinRule;
@Configuration
public class MyConfiguration {
	
	@Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }
	
	/**自定义配置ribbon负载均衡算法
	 * @return
	 */
	@Bean
	public IRule myRule(){
		//return new RoundRobinRule();//轮询
		//return new RandomRule(); //随机
		//return new AvailabilityFilteringRule();//权重
		return new RetryRule(); //重试
	}
}
